#pragma once
#include "LinkFabric.hpp"
#include "Message.hpp"
#include "Crypto.hpp"
#include <map>
#include <string>

namespace linkfabric {
class SDK {
public:
    // bool init(const std::string& devicePath);
    SDK(MemLink& mem) : fabric_(mem) {}
    int openChannel();
    void closeChannel(int channelId);

    bool sendMessage(int channelId, uint8_t msgType, const std::map<uint8_t, std::string>& fields, const std::string& key = "");
    void onMessage(int channelId, std::function<void(uint8_t msgType, std::map<uint8_t, std::string>)> callback);
    void run();
private:
    LinkFabric fabric_;
    std::map<int, std::function<void(uint8_t, std::map<uint8_t, std::string>)>> handlers_;
};
}
